//
//  DXMLObjectThing.m
//  DerbyStatter
//
//  Created by glenn andreas on 1/6/14.
//  Copyright (c) 2014 glenn andreas. All rights reserved.
//

#import "DXMLObjectThing.h"

@implementation DXMLObjectThing
+ (NSString *) uniqueID
{
    CFUUIDRef uuid = CFUUIDCreate(kCFAllocatorDefault);
    CFStringRef uuidStr = CFUUIDCreateString(kCFAllocatorDefault, uuid);
    NSString *retval = (NSString *)CFBridgingRelease(uuidStr);
    CFRelease(uuid);
    return retval;
}

- (id) initWithElementName:(NSString *)elementName attributes: (NSDictionary *) attributes
{
    self = [super initWithElementName:elementName attributes: attributes];
    if (self) {
        [self setAttribute:[[self class] uniqueID] forKey:@"uuid"];
    }
    return self;
}
- (NSString *) name
{
    return [self attributeForKey:@"name"];
}
- (void) setName:(NSString *)name
{
    [self setAttribute:name forKey:@"name"];
}
- (NSString *) uuid
{
    return [self attributeForKey:@"uuid"];
}
- (void) setUuid:(NSString *)uuid
{
    [self setAttribute:uuid forKey:@"uuid"];
}
@end
